package com.prime.tutorial.moviestore.dao;

import org.springframework.stereotype.Repository;

import javax.persistence.Query;
import java.util.List;


@Repository
public class ReportsDAOWithJPA extends GenericDAOWithJPA<Object, Long> implements ReportsDAO {
    public void Test() {
        Query query = entityManager.createQuery("Select d from Device d,DeviceTypeProperty dtp where d.model.id = dtp.model.id and dtp.property.type = 'PortCount' and dtp.property_value*0.9> " +
                "(select count(dtd.deviceport_from.device) from DeviceToDevice dtd where dtd.deviceport_to.device.id = d.id) ");
//        Query query = entityManager.createQuery("Select d.id from Device d where d.model.id in (select count(dev.id) from Device dev where dev.model=d.model) ");
//        Query query = entityManager.createQuery("Select dtd.deviceport_to.device.id  from DeviceTypeProperty dtp, DeviceToDevice dtd  where  dtd.deviceport_to.device.model.id = dtp.model.id and dtp.property.type = 'PortCount' group by dtd.deviceport_to.device.id having count(dtd.deviceport_from.device)>dtp.id ");
//        Query query = entityManager.createQuery("Select d.id ,dtp.property_value  from Device d,DeviceTypeProperty dtp,DeviceToDevice dtd where d.model.id = dtp.model.id and dtp.property.type = 'PortCount' and dtp.property_value>1 ");
//        Query query = entityManager.createQuery("Select dtd.deviceport_to.device.id , count(dtd.deviceport_from.device) from DeviceToDevice dtd group by dtd.deviceport_to.device.id");
        query.getResultList();
    }

//  String hql = "select s.name, p.name, p.price from Product p inner join p.supplier as s";
//    Query query = session.createQuery(hql);
//    List results = query.list();
//    System.out.println(results);


    
}



